/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.fspike.gui.taxonomytree.rendering;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import javax.swing.Icon;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author Kenneth
 */
public class DefaultTaxonomyTreeNode extends DefaultMutableTreeNode {

    protected Icon icon;

    protected String iconName;
    private String url = "";
    private String taxonomyID = "";
    private boolean hasFasta = true;
    private boolean isSelectedForProcessing = true;
    private boolean hasChildren;
    private boolean explored;
    private String parentName;
    private String parentURL;
    private LinkedHashMap<String, String> childrenURLMap;

    public DefaultTaxonomyTreeNode() {
        this(null);
    }

    public DefaultTaxonomyTreeNode(Object userObject) {
        this(userObject, true, null);
    }

    public DefaultTaxonomyTreeNode(Object userObject, boolean allowsChildren, Icon icon) {
        super(userObject, allowsChildren);
        this.icon = icon;
    }

    public DefaultTaxonomyTreeNode(Object userObject, boolean allowsChildren, Icon icon, String urlAsString) {
        super(userObject, allowsChildren);
        this.icon = icon;
        this.url = urlAsString;
    }

    public void setIcon(Icon icon) {
        this.icon = icon;
    }

    public Icon getIcon() {
        return icon;
    }

    public String getIconName() {
        if (iconName != null) {
            return iconName;
        } else {
            return this.toString();
        }
    }

    public void setIconName(String name) {
        iconName = name;
    }

    public String getURLAsString() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url.replace("Undef", "Tree");
    }

    public void setTaxonomyID(String id) {
        this.taxonomyID = id;
    }

    public String getUrl() {
        return url;
    }

    public String getTaxonomyID() {
        return taxonomyID;
    }

    public boolean hasFasta() {
        return hasFasta;
    }

    public void setHasFasta(boolean hasFasta) {
        this.hasFasta = hasFasta;
    }

    public boolean isSelectedForProcessing() {
        return isSelectedForProcessing;
    }

    public void setSelectedForProcessing(boolean isSelected) {
        this.isSelectedForProcessing = isSelected;
    }

    public boolean hasChildren() {
        if (childrenURLMap == null) {
            return false;
        }
        return !childrenURLMap.isEmpty();
    }

    public void setHasChildren(boolean hasChildren) {
        setWasExplored(true);
        this.hasChildren = hasChildren;
    }

    public boolean wasExplored() {
        return explored;
    }

    public void setWasExplored(boolean explored) {
        this.explored = explored;
    }

    public LinkedHashMap<String, String> getChildrenNameMap() {
        return childrenURLMap;
    }

    public void setChildrenNameMap(LinkedHashMap<String, String> childrenURLMap) {
        this.childrenURLMap = childrenURLMap;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public String getParentURL() {
        return parentURL;
    }

    public void setParentURL(String parentURL) {
        this.parentURL = parentURL;
    }

}
